const app     = getApp(),
      api     = require("../../../utils/api.js"),
      request = require("../../../service/request.js");

Page({
	data:{
		MJDetail:{}
	},
	onLoad:function (params){
		// console.log(params);
		var that = this;
		request.get(`${api.getInterviewExpDetail}?expid=${params.expid}`, {}, app.globalData.sessionid).then(res => {
			var scIcon = res.data.isfavorited? "icon-shoucang" : "icon-shoucang2";	    
	    	console.log(res.data)
		    that.setData({
		    	MJDetail: res.data,
		    	scIcon: scIcon
		    });
		})
	},
	shoucang:function(){
		var that = this;
		console.log("点了收藏");
		if(this.data.scIcon=="icon-shoucang2"){
			var favoritesnum = that.data.MJDetail.favoritesnum + 1;
			this.setData({
				scIcon : "icon-shoucang",
				"MJDetail.favoritesnum":favoritesnum
			})
		}else{
			var favoritesnum = that.data.MJDetail.favoritesnum - 1;
			this.setData({
				scIcon : "icon-shoucang2",
				"MJDetail.favoritesnum":favoritesnum
			})
		}
		var API_SC = "https://wxapp.campushire.online/function/addcollection?classname=exp" + "&infoid=" + that.data.MJDetail.expid;
		request.get(`${api.collectExp}&infoid=${that.data.MJDetail.expid}`, {}, app.globalData.sessionid).then(res => {
			console.log(res.data);
		})
	
	}
});	